<template>
  <div>
    <div style="margin-bottom: 10px">
      <el-button size="mini" :disabled="isbansubmit" type="primary" plain @click="Submit()">提交入库</el-button>
    </div>

    <div class="topbox">
      <el-table
        border
        :data="enterorderlist"
        :stripe="true"
        @row-click="selectRow"
        :header-cell-style="{background:'#e3e5e9',color:'#606266'}"
        :row-style="{height:'5px'}"
        :cell-style="{padding:'5px 0'}"
        tooltip-effect="light"
        highlight-current-row
        style="width: 100%;"
        height="400"
      >
        <el-table-column  label="序号" width="50">
          <template slot-scope="scope">
            <span>{{scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column  prop="statu" label="状态" width="95"></el-table-column>
        <el-table-column  prop="ref" label="入库单号" width="150"></el-table-column>
        <el-table-column prop="dealdate" label="业务日期" width="150"></el-table-column>
        <el-table-column show-overflow-tooltip prop="suppliername" label="供应商" width="300"></el-table-column>
        <el-table-column show-overflow-tooltip prop="goodsmoney" label="采购金额" width="125"></el-table-column>
        <el-table-column prop="tax" label="税金" width="150"></el-table-column>
        <el-table-column prop="moneyandtax" label="税价合计" width="125"></el-table-column>
        <el-table-column prop="paymenttype" label="付款方式" width="95"></el-table-column>
        <el-table-column prop="storename" label="入库仓库" width="95"></el-table-column>
        <el-table-column prop="bizusername" label="业务员" width="95"></el-table-column>
      </el-table>
    </div>
    <div class="diver"></div>
    <div class="bottombox">
      <el-tabs type="border-card">
        <el-tab-pane>
          <span slot="label">
            <i class="el-icon-s-order"></i>
            单号:{{form.order_id}} 供应商:{{form.supplier}}
          </span>
          <div>
            <el-table
              border
              :data="detaillist"
              size="mini"
              :row-style="{height:'5px'}"
              :cell-style="{padding:'5px 0'}"
              height="200"
            >
              <el-table-column  label="序号" width="50">
                <template slot-scope="scope">
                  <span>{{scope.$index + 1}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="code" fixed label="商品编码" width="250"></el-table-column>
              <el-table-column label="商品名称" prop="name" width="200"></el-table-column>
              <el-table-column show-overflow-tooltip prop="spec" label="规格型号" width="250"></el-table-column>
              <el-table-column show-overflow-tooltip prop="count" label="入库数量" width="95"></el-table-column>
              <el-table-column show-overflow-tooltip prop="unitname" label="单位" width="125"></el-table-column>
              <el-table-column prop="price" label="采购单价" width="95"></el-table-column>
              <el-table-column prop="money" label="采购金额" width="95"></el-table-column>
              <el-table-column prop="taxrate" label="税率（%）" width="95"></el-table-column>
              <el-table-column prop="tax" label="税金" width="95"></el-table-column>
              <el-table-column prop="moneywithtax" label="价税合计" width="95"></el-table-column>
              <el-table-column prop="memo" show-overflow-tooltip label="备注" width="95"></el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="clear"></div>
    <Submitstore v-if="dialog_visible" @dialog-close="dialog_visible = false" @refresh="RefreshList" :form="selectedRow"></Submitstore>
  </div>
</template>

<script>
import Submitstore from "./order/submitstore";
export default {
  components: { Submitstore },
  data() {
    return {
      isbansubmit: true,
      dialog_visible: false,
      form: {
        order_id: "空",
        supplier: "空"
      },
      enterorderlist: [],
      detaillist: [],
      checkForm: {
        status: "all"
      },
      selectedRow: {}
    };
  },
  created() {
    this.RefreshList()
  },
  methods: {
    Submit() {
      if (this.selectedRow.id == null) {
        this.$message.error("请选择一个入库单!");
      } else {
        this.dialog_visible = true;
      }
    },
    RefreshList() {
      this.$http.get("purchaseenterlist/list").then(response => {
        this.enterorderlist = response.data;
        window.console.log(this.enterorderlist);
      });
    },
    selectRow(Row) {
      this.selectedRow = JSON.parse(JSON.stringify(Row));
      this.form.order_id = Row.ref;
      this.form.supplier = Row.suppliername;
      this.$http
        .post("orderdetail/somelist", { orderid: Row.orderid })
        .then(response => {
          this.detaillist = response.data;
        });
      if (Row.statu == "已入库") {
        this.isbansubmit = true;
      } else {
        this.isbansubmit = false;
      }
    }
  }
};
</script>

<style>
</style>